<!--
 * @Author: your name
 * @Date: 2021-04-01 11:38:54
 * @LastEditTime: 2021-04-14 14:44:11
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \web\node\views\back\header.html
-->
<!-- 管理系统头部 -->
<div class="header">
    <nav class="navbar navbar-custom">
        <div class="navbar-header">
            <a href="javascript:;" class="navbar-brand">文章类网站后台管理系统</a>
        </div>
        <ul class="nav navbar-nav navbar-right">
            <li><a class="logout" style="cursor: pointer;"><i class="fa fa-sign-out"></i>退出</a></li>
        </ul>
    </nav>
</div>
<script src="node_modules/jquery/dist/jquery.js"></script>
<script>
    $(function () {
        $('.logout').on('click', ()=>{
            $.get('http://localhost:3000/back/user/api/logout', (data)=>{
                if(data.status === 200){ // 退出登录成功
                    alert(data.message);
                    // 删除本地数据
                    localStorage.removeItem('token');
                    sessionStorage.removeItem('userSelectedTag');
                    // 跳转到登录页面
                    window.location.href = 'http://localhost:3000/back/login';
                }
            });
        });
    });
</script>